<template>
    <view>

        <view class="page">
            <view class="name">
                <view class="name_left">
                    <view class="mdTitle titleName">
                        {{company.name}}
                    </view>
                    <view class="md4Text smWhite">{{company.rzjd}} · {{company.gsgm}}</view>
                </view>

                <view class="name_right">
                    <image :src="company.logo" mode=""></image>
                </view>
            </view>

            <!-- <view class="jobDetail">
            <view class=" mdTitle">
                职位详情
            </view>

            <view class="job_address smWhite">
                合肥包河区上海浦东发展银行合肥综合中
                心
            </view>

            <view class="nav smWhite">
                导航
            </view>
        </view> -->


            <view class="jobDetail">
                <view class=" mdTitle">
                    公司介绍
                </view>

                <view class="company_info smWhite">
                    {{company.intro}}
                </view>

            </view>


            <!-- <view class="jobDetail">
            <view class=" mdTitle">
                工商信息
            </view>

            <view class="company_info smWhite">
                <view class="infoItem smWhite" v-for="(info,infoIndex) in companyInfo" :key="infoIndex">
                    <text>{{info.name}}</text> <text>{{info.value}}</text>
                </view>
            </view>
        </view> -->


        </view>
        <view class="topView">
            <view class="headLine" style="align-items: center;">
                <view class="name">
                    <text class="md2Title">职位</text>
                    <text class="md2Text mgrey">{{jobs.length}}</text>
                </view>
                <view style="flex: 1;margin-left: 30rpx;">
                    <u-search v-model="keyword" placeholder="请输入关键字搜索" :showAction="false"></u-search>
                </view>
            </view>

            <view class="types">
                <view class="typeItem md4Text" :class="{choosed: position==''}" @click="position = '';">全部</view>
                <view class="typeItem md4Text" :class="{choosed: position==item}" v-for="(item,index) in positions" :key="index" @click="position = item;">{{item}}</view>
            </view>

            <view class="content">
                <view class="cardItem" v-for="(item, index) in jobs" :key="index"
                    @tap="_toView('views/detail/index?id=' + item.id)" v-show="(!keyword || item.title.indexOf(keyword) > -1) && (!position || item.position == position)">
                    <view class="title mdTitle Han">
                        {{item.title}}
                    </view>
                    <view class="msg Han mdText">
                        <text>{{company.rzjd}}</text>
                        <text>{{company.gsgm}}</text>
                    </view>

                    <view class="tags mdText Han">
                        <view class="tag">
                            {{item.position}}
                        </view>
                        <view class="tag">
                            {{item.gzjy == '不限' ? '经验不限' : item.gzjy}}
                        </view>
                        <view class="tag">
                            {{item.zgxl == '不限' ? '学历不限' : item.zgxl}}
                        </view>
                    </view>

                    <view class="hr">
                        <image :src="company.logo" mode=""></image>
                        <text class="md2Text">{{company.shortname || company.name}}</text>
                    </view>

                    <text class="salary mdTitle Han">
                        {{item.salary_min}}-{{item.salary_max}}K
                    </text>

                    <text class="position md2Text Han">
                        {{item.prov}}{{item.city}}
                    </text>
                </view>
            </view>
        </view>

    </view>
</template>

<script>
    export default {
        data() {
            return {
                id: 0,
                company: {},
                jobs: [],
                positions: [],
                position: '',
                keyword: ''
            }
        },
        onLoad(options) {
            this.id = options.id || 1;
            this.getCompanyInfo();
        },
        methods: {
            getCompanyInfo() {
                this._ajax({
                    url: '/api/index/getCompanyInfo',
                    data: {
                        id: this.id
                    },
                    success: res => {
                        if (res.code == 1) {
                            this.company = res.data.company;
                            this.jobs = res.data.jobs;
                            for(var i in this.jobs) {
                                if(this.positions.indexOf(this.jobs[i].position)) {
                                    this.positions.push(this.jobs[i].position);
                                }
                            }
                        } else {
                            this._toast(res.msg);
                        }
                    }
                }, 1);
            }
        }
    }
</script>

<style scoped lang="less">
    .page {
        width: 100%;
        // height: 100vh;
        height: auto;
        background: #404551;
        color: #FFFFFF;
        padding: 60upx 30upx 120rpx;

        .name {
            display: flex;
            justify-content: space-between;

            .name_left {
                .titleName {
                    padding-bottom: 30upx;
                }
            }

            .name_right {
                image {
                    width: 112upx;
                    height: 112upx;
                    border-radius: 50%;
                }
            }
        }

        .jobDetail {
            position: relative;
            margin-top: 54upx;

            .nav {
                position: absolute;
                right: 0;
                bottom: 0;
                width: 154upx;
                height: 68upx;
                border: 2upx solid #FFFFFF;
                opacity: 1;
                border-radius: 66upx;
                text-align: center;
                line-height: 68upx;
            }

            .job_address {
                max-width: 504upx;
                padding-top: 30upx;
            }

            .company_info {
                width: 686upx;
                margin: 26upx auto;
                line-height: 44upx;

                .open {
                    color: #787878;
                }
            }
        }


    }

    .topView {
        width: 100%;
        margin-top: -60rpx;
        // height: 100vh;
        // position: fixed;
        // top: calc(100vh - 180upx);
        color: #333;
        background-color: #fff;
        border-radius: 66upx 66upx 0px 0px;
        // left: 0;
        padding: 0 30upx;
    }

    .headLine {
        width: 100%;
        padding: 42upx 30upx 20upx 30upx;
        display: flex;
        justify-content: space-between;
        border-bottom: 2upx solid #e5e5e5;

        .name {
            text {
                &:nth-child(1) {
                    font-weight: bold;
                    padding-right: 10upx;
                }

                &:nth-child(1) {
                    font-weight: bold;
                }
            }
        }

        .search {
            image {
                width: 40upx;
                height: 40upx;
            }
        }
    }

    .types {
        display: flex;
        padding: 15upx 0;

        .typeItem {
            min-width: 100upx;
            height: 56upx;
            background: #FFFFFF;
            border: 1px solid #CCCCCC;
            opacity: 1;
            text-align: center;
            line-height: 56upx;
            border-radius: 66upx;
            margin-right: 30upx;
            padding: 0 20rpx;
            box-sizing: border-box;
        }

        .choosed {
            border: 2upx solid #3465B1;
            color: #3465B1;
        }
    }

    .content {
        // height: calc(100% - 197upx);
        overflow: auto;
        padding-bottom: 30rpx;
    }

    .cardItem {
        width: 100%;
        height: 275upx;
        background-color: #fff;
        margin: 10upx auto;
        padding-left: 32upx;
        position: relative;

        .title {
            color: #333;
            font-weight: normal;
            padding-top: 28upx;
            padding-right: 150rpx;
        }

        .msg {
            padding-top: 20upx;
            color: #999999;

            text {
                padding-right: 30upx;
            }
        }

        .tags {
            display: flex;
            margin-top: 24upx;

            .tag {
                // width: 104upx;
                padding: 0 10upx;
                height: 42upx;
                line-height: 42upx;
                text-align: center;
                background-color: #F3FAFF;
                margin-right: 20upx;
            }
        }

        .hr {
            margin-top: 18upx;

            image {
                width: 72upx;
                height: 72upx;
                vertical-align: middle;
                margin-right: 10upx;
                border-radius: 50%;
            }
        }

        .salary {
            position: absolute;
            color: #3465B1;
            top: 28upx;
            right: 36upx;
        }

        .position {
            position: absolute;
            color: #CCCCCC;
            right: 44upx;
            bottom: 42upx;
        }
    }
</style>
